﻿#include "EventHandlerTrayConnection.hpp"
#include "TaskManager.hpp"
#include "TheApp.hpp"
#include "cybertron/core/UtilStateHelper.hpp"
EventHandlerTrayConnection::EventHandlerTrayConnection(){

}

EventHandlerTrayConnection::~EventHandlerTrayConnection(){
}

void EventHandlerTrayConnection::onFromNodeRegisterAtTray(SocketBasePtr pSocket){
	if (pSocket != nullptr) {
		mTraySocket = pSocket;
	}
	sendRegisterAtMasterRet(pSocket, Common::ESimOneOK);
}

void EventHandlerTrayConnection::sendRegisterAtMasterRet(SocketBasePtr pSocket, Common::ESimOneErrorCode code){
	Agent::WorkNodeRegisterRet data;
	data.set_code(code);
	pSocket->send(Agent::ENodeRegisterAtAgentRet, data);
}

void EventHandlerTrayConnection::onFromTrayGetAgentInitInfo(Message & msg)
{
	if (!mTraySocket)
		return;
	Agent::SyncAgentPitInfo data;
	data.set_authcode(mAuthCode);
	data.set_authstatus(mAuthStatus);
	data.set_loginstatus(mLoginStatus);
	mTraySocket->send(Agent::EGetAgentInitInfoRet, data);
	logInfo("-------------------onFromTrayGetAgentInitInfo----------------------auth:%d login:%d", mAuthStatus, mLoginStatus);
}

